<?php

namespace App\Http\ControllersVer1;

use Illuminate\Http\Request;

use Qiniu\Auth as QiniuAuth;
use Qiniu\Storage\UploadManager;

class QiniuController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function makeToken4Upload(Request $request) {
        //

        $access_key = 'jJFnbu1d_AFVRMbZ9h769Oh3lhX-L3qPFyEVXAV3';
        $secret_key = '_o1UDQRXEWnDN0hilupKM7VpPBPViKAvuZ8dfenc';

        $auth = new QiniuAuth($access_key, $secret_key);
        $bucket = 'linknow-test';
        $upload_token = $auth->uploadToken($bucket);

        return response()->json([
            'code' => 200,
            'msg' => 'success.',
            'env' => env('APP_ENV'),
            'upload_token' => $upload_token
        ]);
    }


}
